﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Application;
using Business;
using System.Web.UI.HtmlControls;

namespace UserControls
{
    public partial class Paragraph : System.Web.UI.UserControl
    {
        
        public string ParagraphID 
        {
            get { return paragraphId.Value; }
            set { paragraphId.Value = value; }
        }

        public string Title
        {
            get { return lblParagraphTitle.Text; }
            set 
            { 
                lblParagraphTitle.Text = value;
                txtTitle.Text = value;
            }
        }

        public string Content
        {
            get { return pContent.InnerText; }
            set 
            {
                pContent.InnerText = value;
                txtContent.Text = value;
            }
        }

        public void UpdateEditParagraphPanel()
        {
            updatePanelEditParagraph.Update();
        }

        protected void update_Click(object sender, EventArgs e)
        {
            System.Threading.Thread.Sleep(3000);
            lblParagraphTitle.Text = txtTitle.Text;
            pContent.InnerText = txtContent.Text;
            VOParagraph paragraph = new VOParagraph();
            paragraph.ID = ParagraphID;
            paragraph.Title = txtTitle.Text;
            paragraph.Content = txtContent.Text;
            paragraph.Description = "updated";
            BusinessParagraph.UpdateParagraph(paragraph);
            updatePanelEditParagraph.Update();
        }

        protected void delete_Click(object sender, EventArgs e)
        {
            System.Threading.Thread.Sleep(2000);
            if (Session[Title] != null)
            {
                Session.Remove(Title);
            }
            updatePanelEditParagraph.Update();
        }
    }
}